//Wednesday, September 28, 2011 18:08 PDT
import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.awt.geom.*;

public class ThreeTeleports
{
	public int shortestDistance(int xMe, int yMe, int xHome, int yHome, String[] teleports)
	{
		long dist = Math.abs(xMe - xHome) + Math.abs(yMe - yHome);
		for(int i=0; i<teleports.length; i++){
			String[] strs = teleports[i].split(" ");
			int x1 = Integer.parseInt(strs[0]);
			int y1 = Integer.parseInt(strs[1]);
			int x2 = Integer.parseInt(strs[2]);
			int y2 = Integer.parseInt(strs[3]);
			String[] teles = new String[teleports.length - 1];
			for(int j=0, k=0; j<teleports.length; j++){
				if(i!=j){
					teles[k++] = teleports[j];
				}
			}
			
			dist = Math.min(dist, Math.abs(xMe - x1) + Math.abs(yMe - y1) + 10L + shortestDistance(x2, y2, xHome, yHome, teles));
			dist = Math.min(dist, Math.abs(xMe - x2) + Math.abs(yMe - y2) + 10L + shortestDistance(x1, y1, xHome, yHome, teles));
		}
		return (int)dist;
	}	
}
//Powered by [KawigiEdit] 2.0!
